package vip.xiaonuo.smzq.modular.lifecycle.po.datamanager;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import vip.xiaonuo.smzq.modular.lifecycle.constant.LifeCycleConstant;
import vip.xiaonuo.smzq.modular.lifecycle.entity.KclKs;
import vip.xiaonuo.smzq.modular.lifecycle.entity.LifeCycleMineStore;
import vip.xiaonuo.smzq.modular.lifecycle.entity.LifeCyclePedigee;

import java.time.LocalDate;
import java.util.List;

/**
 * 查询矿山信息参数实体
 * @auter GEOSCENE_于彦飞
 * @date 2024/02/20
 */
@Data
public class SaveLCNodePO extends LifeCycleMineStore {
//    @ApiModelProperty("是否分立")
//    private boolean isDiscrete;
    @ApiModelProperty("源族谱节点id列表")
    private List<List<String>> srcPedigeeVals;

    @ApiModelProperty("源族谱节点列表分立")
    private List<String> flSrcPedVals;

    @ApiModelProperty("源族谱id列表")
    private String parentId;

    @ApiModelProperty("族谱列表")
    private List<LifeCyclePedigee> lifeCyclePedigeeList;

    @ApiModelProperty("下一个族谱")
    private List<String> nextPedigeeVals;

    @ApiModelProperty(value = "上一个生命周期节点日期")
    private LocalDate preStoreDate;

    @ApiModelProperty(value = "新立索引")
    private Integer xlIndex;


    public void init(){

        if(!this.getIsDiscrete()){
            if(CollUtil.isNotEmpty(srcPedigeeVals)){
                for (List<String> srcPedVal:srcPedigeeVals) {
                    this.parentId = CollUtil.join(srcPedigeeVals,",",ele->{
                        return CollUtil.getLast(ele);
                    });
                }
            }

        }else{
           this.parentId = CollUtil.getLast(flSrcPedVals);
        }

    }

    public void initExporeType(){
        if(StrUtil.equals(CollUtil.getFirst(LifeCycleConstant.flPedTypes),super.getReportName())){
            super.setExporeType(Convert.toInt(CollUtil.get(LifeCycleConstant.mineTypeCodes,1)));
        }else if(StrUtil.equals(CollUtil.get(LifeCycleConstant.flPedTypes,1),super.getReportName())){
            super.setExporeType(Convert.toInt(CollUtil.get(LifeCycleConstant.mineTypeCodes,2)));
        }
    }

}
